import format from "date-fns/format";
export default (_self, h) => {
	return h("el-date-picker", {
		props: {
			value: _self.obj.value || "",
			placeholder: _self.obj.placeholder,
			// year/month/date/dates/ week/datetime/datetimerange/ daterange/monthrange
		},
		attrs: {
			disabled: !_self.obj.status,
			type: _self.obj.dateType,
			"value-format": _self.obj.dateType === "datetime" ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd",
		},
		on: {
			input: e => {
				if (e) {
					_self.obj.value = e;
				} else {
					_self.obj.value = "";
				}
			},
		},
	});
};

export const datePickerConf = {
	status: true, // 启用状态，0启用；1停用
	elementWidth: "100%",
	elementType: "datePicker", // 对应数据库内类型
	elementName: "日期时间", // 控件左侧label内容
	placeholder: "请选择时间",
	value: format(new Date(), "yyyy-MM-dd HH:mm:ss"), // 绑定的值
	detailList: [], // 选项内数据
	dateType: "datetime",
	icon: "el-icon-date",
	required: false,
	rules: [],
};
